using System;
using System.Collections;
using NHibernate.Cfg;
using Environment = NHibernate.Cfg.Environment;
using NHibernate.Spatial.Dialect;
using NUnit.Framework;
using NHibernate.Driver;

namespace Tests.NHibernate.Spatial
{
	public static class TestConfiguration
	{
		// Output the DDL code the console.
		public const bool OutputDdl = false;

		// Here you can enable the execution of tests by dialect configured
		public const bool MsSqlSpatialFixturesEnabled = true;
		public const bool PostGisFixturesEnabled = true;

		public static void ConfigureMsSqlSpatial(Configuration configuration)
		{
			if (!MsSqlSpatialFixturesEnabled)
				Assert.Ignore();

			IDictionary properties = new Hashtable();
			properties[Environment.Dialect] = typeof(MsSqlSpatialDialect).AssemblyQualifiedName;
			properties[Environment.ConnectionProvider] = typeof(DebugConnectionProvider).AssemblyQualifiedName;
			properties[Environment.ConnectionDriver] = typeof(SqlClientDriver).AssemblyQualifiedName;
			properties[Environment.ConnectionString] = 
				@"Server=localhost\sqlexpress;Initial Catalog=nhs_test;Integrated Security=True";
			//properties[Environment.Hbm2ddlAuto] = "create-drop";
			configuration.SetProperties(properties);
		}

		public static void ConfigurePostGis(Configuration configuration)
		{
			if (!PostGisFixturesEnabled)
				Assert.Ignore();

			IDictionary properties = new Hashtable();
			properties[Environment.Dialect] = typeof(PostGisDialect).AssemblyQualifiedName;
			properties[Environment.ConnectionProvider] = typeof(DebugConnectionProvider).AssemblyQualifiedName;
			properties[Environment.ConnectionDriver] = typeof(NpgsqlDriver).AssemblyQualifiedName;
			properties[Environment.ConnectionString] =
				@"Server=localhost;Port=5432;Database=nhs_test;User Id=nhs_test;Password=nhs_test;Encoding=UNICODE;";
			//properties[Environment.Hbm2ddlAuto] = "create-drop";
			configuration.SetProperties(properties);
		}

	}
}
